package com.moneyanalyzer.sms;

import android.content.Intent;
import android.telephony.SmsManager;
import android.telephony.SmsMessage;
import android.util.Log;

public class SMSUtils {
	public void enviarSms(String numero, String msg) {

	    SmsManager smsManager = SmsManager.getDefault();
	    smsManager.sendTextMessage(numero, null, msg, null, null);
	  }

	  public static SmsMessage[] getMessagesFromIntent(Intent intent){
		  Log.d("SMSUtils.getMessagesFromIntent: ", "recebendo mensagem.");
		  Object[] pdusExtras =
		    (Object[])intent.getSerializableExtra("pdus");
	
		  SmsMessage[] messages =
		    new SmsMessage[pdusExtras.length];
	
		  for (int i = 0; i < pdusExtras.length; i++) {
		    messages[i] = SmsMessage.createFromPdu((byte[])pdusExtras[i]);
		  }
		  return messages;
	  }
}
